<template>
	<view class="user">
		<!-- 浏览历史图标 -->
		<view class="top">
			<image src="../../static/images/history.png" mode="aspectFit"></image>
			<view class="history">浏览记录</view>
		</view>
		<!-- 浏览记录 -->
		<view class="list" v-for="item in hisList" :key="item.id">
			<newsbox :item="item" @click.native="getDetial(item.classid,item.id)"></newsbox>
		</view>
		<!-- 暂无记录 -->
		<view class="nolist" v-if="!hisList.length">
			<image src="../../static/images/nopic.jpg" mode="aspectFit"></image>
			<view>暂无记录</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hisList: []
			};
		},
		onShow() {
			this.getHisList()
		},
		methods: {
			// 获取历史记录
			getHisList() {
				this.hisList = uni.getStorageSync("historyList") || []
				console.log(this.hisList)
			},
			//点击跳转获取详情
			getDetial(cid, id) {
				uni.navigateTo({
					url: `/pages/detail/detail?cid=${cid}&id=${id}`
				})
			},
		},

	}
</script>

<style lang="scss">
	.user {
		margin: 15rpx;

		font-size: 46rpx;


		.top {

			text-align: center;

			image {
				height: 150rpx;
				// border: 1rpx solid red;
			}

			.history {
				image {
					height: 250rpx;
				}

				// border: 1rpx solid red;
			}


		}

		.list {}

		.nolist {
			text-align: center;
		}
	}
</style>